<template>
<uni-shadow-root class="polyv-sdk-components-questionnaire-result-questionnaire-result"><view class="plv-mp-questionnaire-result" :style="'z-index: '+(zIndex)" v-if="showPanel && questions.length > 0">
  <view class="plv-mp-questionnaire-result-head">
    问卷结果
    <view class="plv-mp-questionnaire-result-head__close" @click="closePanel">×</view>
  </view>
  <view class="plv-mp-questionnaire-result-body">
    <view class="plv-mp-questionnaire-result-body__title" v-if="qTitle">{{ qTitle }}</view>
    <view class="plv-mp-questionnaire-result-body__questions">
      <view v-for="(item,index) in (questions)" :key="item.questionId" class="plv-mp-questionnaire-result-body__questions-item plv-mp-result-question">
        <view class="plv-mp-result-question__title">
          {{index + 1}}.【{{item.questionType}}】{{item.name}}
          <text v-if="item.required === 'Y'" class="plv-mp-questionnaire-result__text--required">*</text>
          <text v-if="item.score" class="plv-mp-questionnaire-result__text--blue"> ({{item.score}}分)</text>
        </view>
        <view v-for="(optionItem,index) in (item.selectData)" :key="optionItem.optionIndex" class="plv-mp-result-question-option" v-if="item.type !== 'Q'">
          <view :class="'plv-mp-result-question-option-item '+(optionItem.type ? 'plv-mp-result-question-option-item--' + optionItem.type : '')">
            <view class="plv-mp-result-question-option-item__text">{{optionItem.option}}, {{optionItem.optionText}}</view>
            <image class="plv-mp-result-question-option-item__icon plv-mp-result-question-option-item__icon--wrong" src="../../assets/images/icon-wrong.png"></image>
            <image class="plv-mp-result-question-option-item__icon plv-mp-result-question-option-item__icon--correct" src="../../assets/images/icon-right.png"></image>
          </view>
        </view>
        <block v-if="item.type === 'Q'">
          <view class="plv-mp-result-question__textarea">{{item.answer}}</view>
        </block>
        <view class="plv-mp-result-question-detail">
          <view class="plv-mp-result-question-detail__answer" v-if="item.rightAnswerString">
            正确答案 :
            <text class="plv-mp-questionnaire-result__text--blue">{{item.rightAnswerString}}</text>
          </view>
          <view v-for="(optionItem,index) in (item.selectData)" :key="optionItem.optionIndex" class="plv-mp-result-question-detail__item">
            选{{optionItem.option}}的有
            <text :class="(optionItem.isRightAnswer || (!item.rightAnswerString && optionItem.isMyAnswer)) ? 'plv-mp-questionnaire-result__text--blue' : ''">{{optionItem.AnswerNum}}</text>
            人, 占比 {{optionItem.percent}}%
          </view>
          <block v-if="item.type === 'Q'">
            共有 <text class="plv-mp-questionnaire-result__text--blue">{{item.total}}</text> 人回答。
          </block>
        </view>
      </view>
    </view>
  </view>
  <view class="plv-mp-questionnaire-result-footer">
    <button class="plv-mp-questionnaire-result-footer__confirm" @click="closePanel">我知道了</button>
  </view>
</view></uni-shadow-root>


</template><script>

global['__wxVueOptions'] = {components:{}}

global['__wxRoute'] = 'polyv-sdk/components/questionnaire-result/questionnaire-result'
import store from"../../store/index";import Event from"../../common/chat/eventTypes";Component({properties:{zIndex:{type:Number,default:2e3}},lifetimes:{created(){this.chat=null,this.chatEvent=this.getChatEvent()},attached(){this.unsub=store.get({"main.chat":t=>{this.chat=t,t&&this.bindEvent(this.chatEvent)}})}},data:{qnAchievement:"",qnResultData:"",qTitle:"",words:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",showPanel:!0,questions:[]},methods:{getChatEvent(){const t=this;return{[Event.START_QUESTIONNAIRE]:function(){t.closePanel()},[Event.QUESTIONNAIRE_ACHIEVEMENT]:function(n,o){t.setData({qnAchievement:o},()=>{t.data.qnResultData&&t.data.qnAchievement&&t.init()})},[Event.SEND_QUESTIONNAIRE_RESULT]:function(n,o){t.setData({qnResultData:o},()=>{t.data.qnResultData&&t.data.qnAchievement&&t.init()})}}},bindEvent(t){const n=this.chat;n&&Object.keys(t).forEach(o=>{n.on(o,t[o])})},closePanel(){this.triggerEvent("showPptPaint"),this.setData({showPanel:!1,qnAchievement:"",qnResultData:""})},showPanel(){this.setData({showPanel:!0})},init(){const{qnResultData:t,qnAchievement:n}=this.data,o=t.questionnaireTitle,e=t.data.map((t,o)=>{const e=n.rightAnswer[o],i=n.answer[o];if(t.questionId===i.questionId&&t.questionId===e.questionId){const n=i.answer;if("Q"!==t.type){const o=e.answer.toUpperCase();t.questionType="R"===t.type?"单选":"多选",t.rightAnswerString=o,t.selectData=[],Object.keys(t).forEach(e=>{if(-1!==e.indexOf("option")&&t[e]){const i=e.substr(6),s=this.data.words[i-1],l=t[e],a=-1!==o.indexOf(s),p=!!n&&-1!==n.indexOf(s),u=t.answerResult[i-1];let r=u/t.total*100;r=r?r.toFixed(2):"0.00";let d="";a&&(d="correct"),p&&(d=a?"my-correct":o&&!a?"wrong":"select"),t.selectData.push({optionIndex:i,option:s,optionText:l,isRightAnswer:a,isMyAnswer:p,AnswerNum:u,percent:r,type:d})}})}else t.questionType="问答",t.answer=n||""}return t});this.showPanel(),this.setData({qnResultData:t,qnAchievement:n,qTitle:o,questions:e})},mock(){this.setData({qnAchievement:{EVENT:"QUESTIONNAIRE_ACHIEVEMENT",totalScore:100,userId:"1597714236967",timestamp:1597728912036,roomId:"1808888",questionnaireId:"fqciilpzyc",answer:[{questionId:"81bb96d738",answer:"A"},{questionId:"eace92a159",answer:"A"},{questionId:"815ad5d1f8",answer:"A"},{questionId:"1cdacff0ee",answer:"A"},{questionId:"92fd2b01bb"},{questionId:"07d1f07ab2",answer:"A"},{questionId:"fc727a4b6c",answer:"A"},{questionId:"5de23226ff",answer:"B"},{questionId:"98b57b2a60",answer:"A"},{questionId:"840e188cee",answer:"123"},{questionId:"c1a79e4880"},{questionId:"236f94e3d8",answer:"123"},{questionId:"05e5ebbfd3"}],ranking:1,rightAnswer:[{questionId:"81bb96d738",answer:""},{questionId:"eace92a159",answer:""},{questionId:"815ad5d1f8",answer:""},{questionId:"1cdacff0ee",answer:""},{questionId:"92fd2b01bb",answer:""},{questionId:"07d1f07ab2",answer:"a"},{questionId:"fc727a4b6c",answer:""},{questionId:"5de23226ff",answer:"abcd"},{questionId:"98b57b2a60",answer:"c"},{questionId:"840e188cee",answer:""},{questionId:"c1a79e4880",answer:""},{questionId:"236f94e3d8",answer:""},{questionId:"05e5ebbfd3",answer:""}]},qnResultData:{EVENT:"SEND_QUESTIONNAIRE_RESULT",questionnaireId:"fqciilpzyc",questionnaireTitle:"问卷名超级长问卷名超级长问卷名超级长问卷名超级长问卷名超级长 (15)",total:1,data:[{questionId:"81bb96d738",name:"单选超级长单选超级长单选超级长单选超级长单选超级长单选超级长",type:"R",option1:"1",option2:"2",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"eace92a159",name:"&amp;nbsp;",type:"R",option1:"1",option2:"2",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"815ad5d1f8",name:"undefined",type:"R",option1:"null",option2:"&lt;script&gt;alert(a)&lt;script&gt;",option3:"&lt;h1&gt;123123&lt;&#x2F;h1&gt;",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"1cdacff0ee",name:"&lt;h1&gt;dasdaad&lt;&#x2F;h1&gt;",type:"R",option1:"asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf1111asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf11111asdfasdfasdf",option2:"1",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"92fd2b01bb",name:"1212312",type:"R",option1:"123",option2:"1231231",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"N",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:0,totalScore:0,answerResult:[0,0,0,0,0,0,0,0,0,0]},{questionId:"07d1f07ab2",name:"的粉体",type:"R",option1:"1",option2:"2",option3:"",option4:"",option5:"",answer:"a",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"Y",option6:"",option7:"",option8:"",option9:"",option10:null,score:100,itemType:0,option0:"",total:1,totalScore:100,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"fc727a4b6c",name:"多选测试",type:"C",option1:"1",option2:"2",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"5de23226ff",name:"123",type:"C",option1:"1",option2:"2",option3:"2",option4:"3",option5:"",answer:"abcd",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"Y",option6:"",option7:"",option8:"",option9:"",option10:null,score:99,itemType:0,option0:"",total:1,totalScore:0,answerResult:[0,1,0,0,0,0,0,0,0,0]},{questionId:"98b57b2a60",name:"1231231231231",type:"C",option1:"1",option2:"2",option3:"3",option4:"",option5:"",answer:"c",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"Y",option6:"",option7:"",option8:"",option9:"",option10:null,score:1,itemType:0,option0:"",total:1,totalScore:0,answerResult:[1,0,0,0,0,0,0,0,0,0]},{questionId:"840e188cee",name:"213123123123123123123123123123",type:"Q",option1:"",option2:"",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:1,totalScore:0,answerResult:[0,0,0,0,0,0,0,0,0,0]},{questionId:"c1a79e4880",name:"2",type:"Q",option1:"",option2:"",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"N",scoreEnabled:"N",option6:"",option7:"",option8:"",option9:"",option10:null,score:null,itemType:0,option0:"",total:0,totalScore:0,answerResult:[0,0,0,0,0,0,0,0,0,0]},{questionId:"236f94e3d8",name:"1",type:"Q",option1:"",option2:"",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"Y",scoreEnabled:"Y",option6:"",option7:"",option8:"",option9:"",option10:null,score:1,itemType:0,option0:"",total:1,totalScore:0,answerResult:[0,0,0,0,0,0,0,0,0,0]},{questionId:"05e5ebbfd3",name:"12312312312123123",type:"Q",option1:"123",option2:"3123123",option3:"",option4:"",option5:"",answer:"",tips1:null,tips2:null,tips3:null,tips4:null,tips5:null,required:"N",scoreEnabled:"Y",option6:"",option7:"",option8:"",option9:"",option10:null,score:99,itemType:0,option0:"",total:0,totalScore:0,answerResult:[0,0,0,0,0,0,0,0,0,0]}]}},()=>{this.init()})}}});
export default global['__wxComponents']['polyv-sdk/components/questionnaire-result/questionnaire-result']
</script>
<style platform="mp-weixin">
.plv-mp-questionnaire-result{position:absolute;top:0;display:flex;flex-direction:column;height:100%;width:100%;background:#fff}.plv-mp-questionnaire-result-head{position:relative;padding:17px 16px;color:#333;font-size:14px;line-height:14px;background:#fff;border:1px solid #eceff1;word-break:break-all;text-align:center}.plv-mp-questionnaire-result-head__close{position:absolute;top:0;bottom:0;margin:auto;right:0;width:50px;height:14px;color:#90a4ae;text-align:center;font-size:25px}.plv-mp-questionnaire-result-body{padding:0 23px;flex:1;overflow-y:auto}.plv-mp-questionnaire-result-body__title{margin:22px 0;text-align:center;color:#333;font-size:16px;font-weight:600;word-break:break-all}.plv-mp-questionnaire-result-body .plv-mp-result-question{margin-bottom:20px;color:#455a64}.plv-mp-questionnaire-result-body .plv-mp-result-question__title{margin-bottom:20px;color:#333;word-break:break-all;font-size:16px}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item{position:relative;width:100%;margin-top:12px;padding:10px 16px;background:#edf1f7;border-radius:20px;font-size:14px;color:#546e7a;box-sizing:border-box}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item__text{padding-right:25px;word-break:break-all}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item__icon{display:none;position:absolute;right:16px;top:0;bottom:0;margin:auto;width:16px;height:16px}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--select{background:#c0e3ff;color:#2196f3}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--wrong{background:#ffe3e3;color:#e45b5b}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--wrong .plv-mp-result-question-option-item__icon--wrong{display:inline-block}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--my-correct{background:#c0e3ff;color:#2196f3}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--my-correct .plv-mp-result-question-option-item__icon--correct{display:inline-block}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-option-item--correct{background:#c0e3ff;color:#2196f3}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-detail{position:relative;margin-top:20px;padding:16px;background:#edf1f7;border-radius:5px;font-size:14px}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-detail__answer{font-weight:600;margin:0 0 8px}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-detail__item{line-height:22px}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question-detail:before{content:"";position:absolute;top:-6px;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #edf1f7}.plv-mp-questionnaire-result-body .plv-mp-result-question .plv-mp-result-question__textarea{display:inline-block;width:100%;min-height:80px;max-height:180px;padding:8px 10px;border:1px solid #cfd8dc;font-size:14px;color:#333;word-break:break-all;overflow-y:auto;vertical-align:bottom;border-radius:4px;box-sizing:border-box}.plv-mp-questionnaire-result-footer{height:79px;padding:15px 23px;border:0;box-sizing:border-box}.plv-mp-questionnaire-result-footer__confirm{width:100%;height:48px;margin:0;background:#2196f3;color:#fff;border:0;border-radius:25px}.plv-mp-questionnaire-result__text--blue{color:#2196f3}.plv-mp-questionnaire-result__text--required{color:#ff5722}
	.chucuno {
		position: absolute;
		top: 50%;
		margin-top: -150rpx;
		z-index: 99999;
		left: 50%;
		margin-left: -325rpx;
	}

.back-tankuang {
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 99999;
		height: 100%;
		background: rgba(51, 51, 51, 0.5);
	}</style>